<?php
/* @var $this TradeController */
/* @var $model Trade */
/* @var $form CActiveForm */
//行业分类
$category = $model->category;
?>



<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'trade-form',
	'enableClientValidation'=>true,
)); ?>

	<ul class="form_list form_list2 mt10">
		<li class="c_f"><span class="tit"><em class="xing">*</em>选择类目：</span>
			<div class="cont f_l">
				<span id="catagory" >
					<select name="cateid1" class="level_1 s_ipt w_120" id="dataProductIndustryId1" ></select>
					<select name="cateid2" class="level_2 s_ipt w_120" id="dataProductIndustryId2"></select>
					<select name="cateid3" class="level_3 s_ipt w_120" id="dataProductIndustryId3" ></select>
				</span>
				<span id="categoryTip"></span>
			</div>
		</li>
		<li class="c_f"><span class="tit"><em class="xing">*</em>标题：</span>
			<div class="cont f_l">
				<?php echo $form->textField($model,'ztr_title',array('class'=>'t_ipt w_300'))?>
				<?php echo $form->error($model,'ztr_title')?>
			</div>
		</li>
		<li class="c_f"><span class="tit"><em class="xing">*</em>采购数量：</span>
			<div class="cont f_l">
				<?php echo $form->textField($model,'ztr_nums',array('class'=>'t_ipt w_170'))?>
				<span>单位：
					<?php echo $form->textField($model,'ztr_unit',array('class'=>'t_ipt w_40'))?>
					<?php echo $form->error($model,'ztr_unit')?>
					<?php echo $form->error($model,'ztr_title')?>
				</span>
			</div>
		</li>
		<li class="c_f"><span class="tit"><em class="xing">*</em>价格要求：</span>
			<div class="cont f_l">
					<?php echo $form->textField($model,'ztr_price',array('class'=>'t_ipt w_170'))?>
					<?php echo $form->error($model,'ztr_price')?>
			</div>
		</li>
		<li class="c_f"><span class="tit"><em class="xing">*</em>有效期至：</span>
			<div class="cont f_l">
				<?php echo $form->textField($model,'ztr_exp_time',array('onclick'=>"WdatePicker()",'class'=>'t_ipt ipt_bg'))?>			
				<?php echo $form->error($model,'ztr_exp_time')?>
			</div>
		</li>
		<li class="c_f"><span class="tit">产品图片：</span>
			<div class="cont f_l cont">
				<div class="uploadimg">
					<img id="img1" src="<?php if(!empty($model->ztr_pic)){echo $model->ztr_pic;}else{echo "/images/pro_img.jpg";}?>" alt="" />
				</div>
				<p class="mt10">
					<?php echo CHtml::link('上传图片<b class="mem_bgx left"></b><b class="mem_bgx right"></b>'.CHtml::fileField('image','',array('id'=>'uploadimg1','multiple'=>true)),'javascript:',array('class'=>'mem_bgx link_btn filelink mr20','onclick'=>"uploadimg('1')"))?>
					<?php echo $form->hiddenField($model,'ztr_pic',array('id'=>'proimage1'))?>	
				</p>						
			</div>
		</li>
		<li class="c_f"><span class="tit"><em class="xing">*</em>商品描述：</span>
			<div class="cont f_l">
				<?php  $this->widget('ext.keditor.KEditor',array(
		            'model'=>$model,  //传入form model
		            'name'=>'ztr_content', //设置name
		            'properties'=>array(
		                //设置接收文件上传的action
		                'uploadJson'=>'/Attachment/GetAjax',
		                //设置浏览服务器文件的action，这两个就是上面配置在/admin/default的
		             //   'fileManagerJson'=>'/Attachment/GetAjax',
		                'newlineTag'=>'br',
		                'allowFileManager'=>true,
		                //传值前加js:来标记这些是js代码
		                'afterCreate'=>"js:function() {
		                        K('#ChapterForm_all_len').val(this.count());
		                        K('#ChapterForm_word_len').val(this.count('text'));
		                    }",
		                'afterChange'=>"js:function() {
		                        K('#ChapterForm_all_len').val(this.count());
		                        K('#ChapterForm_word_len').val(this.count('text'));
		                    }",
		            ),
		            'textareaOptions'=>array(
		                'style'=>'width:700px;height:261px;',
		            )
		        )); ?>
				<p class="c_999">上传图片规格：宽度不能超过750px</p><?php echo $form->error($model,'ztr_content')?>
			</div>
		</li>
		<li class="c_f"><span class="tit"><em class="xing">*</em>所在地区：</span>
			<div class="cont f_l">
				<?php Area::getAreainfo('Trade',$model->zar_id,'i_ipt w_120 mr10');?>
				<?php echo $form->error($model,'zar_id')?>	
			</div>
		</li>
		<li class="c_f"><span class="tit"><em class="xing">*</em>联系人：</span>
			<div class="cont f_l">
				<?php echo $form->textField($model,'ztr_linkman',array('class'=>'t_ipt w_170 mr10'))?>
				<?php echo $form->error($model,'ztr_linkman')?>		
			</div>
		</li>
		<li class="c_f"><span class="tit"><em class="xing">*</em>联系电话：</span>
			<div class="cont f_l">
				<?php echo $form->textField($model,'ztr_mob',array('class'=>'t_ipt w_170 mr10'))?>
				<?php echo $form->error($model,'ztr_mob')?>		
			</div>
		</li>
		<li class="c_f"><span class="tit">是否头条：</span>
			<div class="cont f_l">
				<div class="f_l mr30"><?php echo $form->radioButtonList($model,'ztr_uregent',Trade::model()->getCtrUregent(),array('class'=>'radio','labelOptions'=>array('class'=>'mr10')))?></div>
				<div class="f_l"><span class="">是否推荐：</span><?php echo $form->radioButtonList($model,'ztr_commend',Trade::model()->getZtrCommend(),array('class'=>'radio','labelOptions'=>array('class'=>'mr10')))?></div>
			</div>
		</li>
		<li class="c_f"><span class="tit">&nbsp;</span>
			<div class="cont f_l">
				<?php echo CHtml::submitButton(Yii::t("adm","Create Trade"),array('class'=>'mem_btn mem_btn20 mr5'))?>
				<?php echo CHtml::resetButton(Yii::t('adm',"Reset"),array('class'=>'mem_btn mem_btn07'))?>
			</div>
		</li>
	</ul>	

<?php $this->endWidget(); ?>

<script src="<?php echo Yii::app()->baseUrl;?>/js/upload_img.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo Yii::app()->baseUrl;?>/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/js/multi_select.js"></script>

<script type="text/javascript">
//渲染行业分类默认选中值
$.getJSON('/cache/GetCategory',function(json){
	var options	= {data	: json};
	var loc = new multi_select(options);
	loc.bind('#catagory .level_1','<?php if(!empty($category)) echo ($category->zca_topid>0)?$category->zca_topid:(($category->zca_parentid>0)?$category->zca_parentid:$category->zca_id)?>');
	loc.bind('#catagory .level_2','<?php if(!empty($category)) echo ($category->zca_topid>0)?$category->zca_parentid:(($category->zca_parentid>0)?$category->zca_id:'')?>');
	loc.bind('#catagory .level_3','<?php if(!empty($category)) echo ($category->zca_topid>0)?$category->zca_id:''?>');
});
//数据验证
$('#trade-form').bind('submit',function(){
	if(($('#dataProductIndustryId3').val()==0)&&($('#dataProductIndustryId2').val()==0)){
		alert("请选择行业分类！");
		$('#catagory').addClass("error");
		return false;
	}
})
</script>